c# linq distinct group by nested list

66

c# linq distinct group by nested list -

var result = hotels.SelectMany(hotel => hotel.RoomType.Select(room => new { Id = room.RoomId, Hotel = hotel }))
                   .GroupBy(item => item.Id)
                   .Select(group => group.FirstOrDefault());

Comments

Submit
0 Comments